package qgs.zisu.javaconcurrency.javaconcurrency.testDXC;

import qgs.zisu.javaconcurrency.javaconcurrency.testDXC.TestThread;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/6 9:06
 * @Version 1.0
 */
public class testApplication {
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        List<Integer> list1 = Arrays.asList(5,4,2,1,6,8,44,2,4,98);
        List<Integer> list2 = Arrays.asList(2,2,2,1,6,8,4,2,4,98);
        List<Integer> list3 = Arrays.asList(78,4,2,1,6,8,14,2,4,98);
        List<Integer> list4 = Arrays.asList(5,4,2,1,6,8,24,2,6,98);
        List<Integer> list5 = Arrays.asList(5,4,2,1,6,8,0,2,4,98);
        List<Integer> list6 = Arrays.asList(4,67,2,4,6,8,2,1,4,98);
        List<Integer> list7 = Arrays.asList(5,4,2,1,4,8,44,2,4,98);
        List<Integer> list8 = Arrays.asList(18,4,2,1,6,8,44,3,4,98);
        List<Integer> list9 = Arrays.asList(9,1,2,18,67,0,44,2,4,98);
        List<Integer> list0 = Arrays.asList(5,3,2,10,6,8,44,9,4,98);

        TestThread testThread1 = new TestThread(list1,list2,list3,list4,list5,list6,list7,list8,list9,list0);
        TestThread testThread2 = new TestThread(list2,list3,list4,list5,list6,list7,list8,list9,list0,list1);
        TestThread testThread3 = new TestThread(list3,list4,list5,list6,list7,list8,list9,list0,list1,list2);
        TestThread testThread4 = new TestThread(list4,list5,list6,list7,list8,list9,list0,list1,list2,list3);
        TestThread testThread5 = new TestThread(list5,list6,list7,list8,list9,list0,list1,list2,list3,list4);
        TestThread testThread6 = new TestThread(list6,list7,list8,list9,list0,list1,list2,list3,list4,list5);
        TestThread testThread7 = new TestThread(list7,list8,list9,list0,list1,list2,list3,list4,list5,list6);
        TestThread testThread8 = new TestThread(list8,list9,list0,list1,list2,list3,list4,list5,list6,list7);
        TestThread testThread9 = new TestThread(list9,list0,list1,list2,list3,list4,list5,list6,list7,list8);
        TestThread testThread10 = new TestThread(list0,list1,list2,list3,list5,list5,list6,list7,list8,list9);




        testThread1.start();
        testThread2.start();
        testThread3.start();
        testThread4.start();
        testThread5.start();
        testThread6.start();
        testThread7.start();
        testThread8.start();
        testThread9.start();
        testThread10.start();

        Integer a1 = testThread1.getSum();
        Integer a2 = testThread2.getSum();
        Integer a3 = testThread3.getSum();
        Integer a4 = testThread4.getSum();
        Integer a5 = testThread5.getSum();

        Integer allSum = testThread1.getSum()+testThread2.getSum()+testThread3.getSum()+testThread4.getSum()+testThread5.getSum()+testThread6.getSum()+testThread7.getSum()+testThread8.getSum()+testThread9.getSum()+testThread10.getSum();
        long endTime = System.currentTimeMillis();

        long date = endTime-startTime;
        String resultDate = transferLongToDate("yyyy-MM-dd HH:mm:ss",date);
        System.err.println("多线程执行时间（long）："+date);
        System.err.println("多线程执行时间："+resultDate);




    }
    /**
     * 把long 转换成 日期 再转换成String类型
     */
    public static String transferLongToDate(String dateFormat, Long millSec) {
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        Date dateSS = new Date(millSec);
        return sdf.format(dateSS);
    }

}
